package com.cn.wanxi.autoconfig.config;

import com.cn.wanxi.autoconfig.interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


/**
 * @ClassName InterceptorConfig
 * @Description 拦截器配置类
 * @Author JiJiang
 * @Date 2022/9/21 23:02
 * @Version 1.0
 */

@Configuration
public class SpringMVConfig implements WebMvcConfigurer {



    //异常拦截器
    @Resource
    private PermissionInterceptor exceptionInterceptor;


    //重写方法，注册拦截器（InterceptorRegistry）
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        //添加异常处理的拦截器
        registry.addInterceptor(exceptionInterceptor).addPathPatterns("/**");

        //注册拦截器类，添加黑名单(addPathPatterns("/**")),‘/*’只拦截一个层级，'/**'拦截全部
        // 和白名单(excludePathPatterns("List类型参数"))，将不必拦截的路径添加到List列表中
//        registry.addInterceptor(loginInterceptor).addPathPatterns("/back/**").excludePathPatterns(exPatternList);


    }


}
